<?php
include_once '../inc/config.inc.php';
include_once '../inc/mysqli.inc.php';
include_once '../inc/tool.inc.php';

$link=connect();
if(!$memberid=is_login($link)){
    $url=urlencode("$_SERVER[REQUEST_URI]");
    skip("login.php?url={$url}",'error','请登陆之后再进行回复！');
}
if(!isset($_GET['id'])||!is_numeric($_GET['id'])||$_GET['id']<1){
    skip('index.php','error','id参数不合法！ ');
}
$queryt="select *from content where id={$_GET['id']}";
$resultt=execute($link,$queryt);
if(mysqli_num_rows($resultt)!=1){
    skip('index.php','error','id参数不合法！ ');
}
$datat=mysqli_fetch_assoc($resultt);
$datat=dehtml($datat);
$queryc="select *from childModule where id={$datat['cmid']}";
$resultc=execute($link,$queryc);
$datac=mysqli_fetch_assoc($resultc);
$datac=dehtml($datac);
$queryf="select *from fatherModule where id={$datac['referid']}";
$dataf=mysqli_fetch_assoc(execute($link,$queryf));
$dataf=dehtml($dataf);
$querym="select *from member where id={$datat['memberid']}";
$resultm=execute($link,$querym);
$datam=mysqli_fetch_assoc($resultm);
$datam=dehtml($datam);


if(isset($_POST['submit'])){
    $_POST=tosqlstring($link,$_POST);
    if(empty($_POST['content'])){
        skip("$_SERVER[REQUEST_URI]",'error','回复内容不得为空！ ');
    }
    $query="insert into reply(contentid,content,time,memberid) values({$_GET['id']},'{$_POST['content']}',now(),$memberid)";
    $result=execute($link,$query);
    if(mysqli_affected_rows($link)==1){
        skip("show.php?id={$_GET['id']}",'ok','回复成功！ ');
    }else{
        skip("$_SERVER[REQUEST_URI]",'error','回复失败，请重试！ ');
    }
}






$template='帖子回复';
include_once 'inc/header.inc.php';
?>



        <div class="qtmain">
                    <div class="wrap">
                        <h2 class="top_dir">
                            <a href="index.php">首页</a>&nbsp;&gt;
                            <a href='<?php echo "parentList.php?id={$dataf['id']}";?>' ><?php echo "{$dataf['moduleName']}";?></a>&nbsp;&gt;
                            <a href='<?php echo "childList.php?id={$datac['id']}";?>' ><?php echo "{$datac['moduleName']}";?></a>&nbsp;&gt;
                            <span>帖子回复</span>
                        </h2>
                        <div class="content">
                            <div class="conttop">回复  由<?php echo "{$datam['name']}";?>发布的： <?php echo "{$datat['title']}";?></div>
                        
                            <form method="post">
                                <textarea name="content" class="text_part" ></textarea>
                                <input type="submit" name="submit" value="回复" class="nsubmit">
                            </form>
                        </div>
                    </div>
                </div>
    
        



 <?php
include_once 'inc/footer.inc.php';
?>